<?php use_helper('I18N') ?>
<div class="content_box_title"><?php echo __('Member Login') ?></div>
<div class="first_login_cont">


<div class="sector_login_cont">
    <label for="sector">
        <?php echo __('Sector')?>
    </label>
<select name="sector" id="login_sector">
    <option value="" ><?php echo __('Select one');?></option>
    <?php foreach(CodeSectorTable::getInstance()->getSectorOptions() as $id => $name){?>
        <option value="<?php echo $id ?>"><?php echo $name; ?></option>
    <?php }?>
</select>
</div>

<div class="level_login_cont" style="display: none;">
    <label for="level">
        <?php echo __('Level')?>
    </label>    
    <select name="level" id="login_level">
        <option value=""></option>
        <?php foreach(LinkProgramLevelTable::getInstance()->getLevels() as $level_id => $level_name){?>
            <option value="<?php echo $level_id?>"><?php echo $level_name?></option>
        <?php }?>
    </select>
</div>

<div class="school_login_cont" style="display: none;">
    <label for="school">
        <?php echo __('School')?>
    </label>    
    <select name="school" id="login_school">
        <option value=""></option>
    </select>
</div>
    
<div id="login_form_cont" class="login_form_cont" style="display: none;">
    <?php echo get_partial('sfGuardAuth/signin_form', array('form' => $form)); ?>
</div>

</div>

<script type="text/javascript">
$(document).ready(function(){
    $('#login_sector').change(function(){
       if($(this).val() != ''){
           $('.level_login_cont').show();
       }else{
           $('.level_login_cont').hide();
       }
    });
    
     $('#login_level').change(function(){
        if($(this).val() != ''){
             $.get('<?php echo url_for('home/ajaxSchoolsBySector'); ?>/intg_id/'+$('#login_sector').val()+'/level_id/'+$(this).val(), function(data){
            var res = eval('('+data+')');
            $('#login_school').html('<option></option>');
            for(id in res){
                $('#login_school').append('<option value="'+id+'">'+res[id]+'</option>');
            }
            $('.school_login_cont').fadeIn('fast');
          });
        }
     });
    
    $('#login_school').change(function(){
       if($(this).val() == ''){
           $('.login_form_cont').fadeOut('fast');
       }else{
           $('.login_form_cont').fadeIn('fast');
       } 
    });
    
});
</script>